package com.cy.pj.sys.controller;

import com.cy.pj.common.pojo.JsonResult;
import com.cy.pj.common.pojo.SysRole;
import com.cy.pj.sys.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class SysRoleController {
    @Autowired
    private SysRoleService sysRoleService;
    @RequestMapping("/role/doFindRoles")
    public JsonResult doFindRoles() {
        return new JsonResult(sysRoleService.findObjects());
    }


    @RequestMapping("/role/doFindObjectById")
    public JsonResult doFindObjectById(Integer id){
        return new JsonResult(sysRoleService.findObjectById(id));
    }


    @RequestMapping("/role/doUpdateObject")
    public JsonResult doUpdateObject(SysRole entity, Integer[] menuIds) {
        sysRoleService.updateObject(entity, menuIds);
        return new JsonResult("update ok");
    }


        @PostMapping("role/doSaveObject")
        public JsonResult doSaveObject (SysRole entity, Integer[]menuIds)
        {
            sysRoleService.saveObject(entity, menuIds);
            return new JsonResult("save ok");
        }


        @RequestMapping("/role/doFindPageObjects")
        public JsonResult doFindPageObjects (String name, Integer pageCurrent)
        {
            return new JsonResult(sysRoleService.findPageObjects(name, pageCurrent));
        }

        @RequestMapping("/role/doDeleteObject")
        public JsonResult doDeleteObject (Integer id){
            sysRoleService.deleteObject(id);
            return new JsonResult("delete ok");
        }

    }
